// /D:/liu_thingsvue/thingsvue/src/api/thingsborad/api/telemetry.ts
import { defHttp } from '/@/utils/http/axios';

enum Api {
  GET_LATEST = '/api/plugins/telemetry/{entityType}/{entityId}/values/timeseries',
}

// 获取最新遥测数据
export const getLatestTelemetry = (params: {
  entityType: string;
  entityId: string;
  keys: string;
}) =>
  defHttp.get<any>({
    url: Api.GET_LATEST.replace('{entityType}', params.entityType).replace(
      '{entityId}',
      params.entityId,
    ),
    params: { keys: params.keys },
  });

// WebSocket URL生成
export const getTelemetryWebSocketUrl = (token: string) =>
  `ws://localhost:8088/api/ws/plugins/telemetry?token=${token}`;
